﻿[assembly: WebActivator.PreApplicationStartMethod(typeof(MongoServices.Example.App_Start.AutoMapperStartup), "Initialize")]

namespace MongoServices.Example.App_Start
{
	using System;
	using System.Collections.Generic;
	using System.Linq;
	using System.Web;
	using AutoMapper;
	using MongoServices.Example.Models.DomainModels;
	using MongoServices.Example.Models.ViewModels;

	public static class AutoMapperStartup
	{
		public static void Initialize()
		{
			Mapper.CreateMap<BlogPost, BlogCreateEditViewModel>();
			Mapper.CreateMap<BlogPost, BlogPostDetailViewModel>()
				.ForMember(dest => dest.DatePosted, opt => opt.MapFrom(src => src.DatePosted.ToLocalTime()));
			Mapper.CreateMap<BlogCreateEditViewModel, BlogPost>();
			Mapper.CreateMap<BlogPostShort, BlogIndexItemViewModel>()
				.ForMember(dest => dest.DatePosted, opt => opt.MapFrom(src => src.DatePosted.ToLocalTime()));

		}
	}
}